package ourGame;

import java.awt.Image;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;

public class Ship
{
	int x, dx, y, dy;
	Image img;
	Map map;
	
	public Ship()
	{
		ImageIcon i = new ImageIcon("images/shipUp.gif");
		img = i.getImage();
		x = 30;
		y = 30;
		map = new Map();
	}
	public void move()
	{
		if((map.isValidMove(x + dx, y + dy)))
		{
			x = x + dx;
			y = y + dy;
		}
	}
	
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public Image getImage()
	{
		return img;
	}
	
	public void setVelocity(int dx, int dy)
	{
		this.dx = dx;
		this.dy = dy;
		
		if(dx > 0)
			img = new ImageIcon("images/shipRight.gif").getImage();
		if(dx < 0)
			img = new ImageIcon("images/shipLeft.gif").getImage();
		if(dy > 0)
			img = new ImageIcon("images/shipDown.gif").getImage();
		if(dy < 0)
			img = new ImageIcon("images/shipUp.gif").getImage();
	}
	
}
